<template>
  <div v-if="viewModel">
    <base-setting v-if="viewModel" v-model="viewModel"></base-setting>
    <el-form-item label="文字" required>
      <el-input v-model="viewModel.text" placeholder="请输入文字信息" size="mini"></el-input>
      <div class="sale-intro" v-html="helpText"></div>
    </el-form-item>
    <el-form-item label="文字大小" required>
      <el-input-number :min="9" :max="100" v-model="viewModel.size" size="mini"></el-input-number>
      <div class="sale-intro">文字大小9px到100px之间</div>
    </el-form-item>
    <el-form-item label="字体颜色">
      <el-color-picker v-model="viewModel.color" size="mini"></el-color-picker>
      <div class="sale-intro">字体的颜色默认黑色</div>
    </el-form-item>
    <el-form-item label="是否加粗">
      <el-switch v-model="viewModel.fontWeight" size="mini"></el-switch>
      <div class="sale-intro">字体是否加粗</div>
    </el-form-item>
    <el-form-item label="是否划线">
      <el-switch v-model="viewModel.lineThrough" size="mini"></el-switch>
      <div class="sale-intro">字体是否从中间划线</div>
    </el-form-item>
  </div>
</template>
<script>
  import baseSetting from './base'
  import ala from 'ala'
export default {
    model: {
      prop: 'dataModel',
      event: 'change'
    },
    components: {
      baseSetting
    },
    props: {
      dataModel: {}
    },
    data () {
      return {
        viewModel: null,
        helpText: ''
      }
    },
    mounted () {
      this.init()
    },
    methods: {
      async init () {
        this.viewModel = this.dataModel
        var qrCodeType = this.$ala.router().query.QrCodeType
        if (qrCodeType === 'Product') {
          this.helpText = '文字信息,可使用如下变量替换：'
          this.helpText += '商品名称：<strong style=\'color:red;padding-right:5px;\'>{{Name}}</strong>'
          this.helpText += '货号：<strong style=\'color:red;padding-right:5px;\'>{{Bn}}</strong>'
        }
        if (qrCodeType === 'Video') {
          this.helpText = '文字信息,可使用如下变量替换：'
          this.helpText += '课程名称：<strong style=\'color:red;padding-right:5px;\'>{{Name}}</strong>'
        }
        if (qrCodeType === 'User') {
          this.helpText = '文字信息,可使用如下变量替换：'
          this.helpText += '用户名称：<strong style=\'color:red;padding-right:5px;\'>{{Name}}</strong>'
        }
        if (qrCodeType === 'Article') {
          this.helpText = '文字信息,可使用如下变量替换：'
          this.helpText += '文字标题：<strong style=\'color:red;padding-right:5px;\'>{{Title}}</strong>'
        }
        if (qrCodeType === 'Course') {
          this.helpText = '文字信息,可使用如下变量替换：'
          this.helpText += '课程名称：<strong style=\'color:red;padding-right:5px;\'>{{Name}}</strong>'
        }
      }
    },
    watch: {
      viewModel: {
        deep: true,
        handler (val) {
          this.$emit('change', this.viewModel)
        }
      }
    }
  }
</script>
